<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="css/eui.css">
    <style>
        body{
            font: 18px "Microsoft YaHei UI";
            margin: 0;
            background-color: #f1f1f1;
        }
        header a{
            text-decoration: none;
            color: #FFFFFF;
        }
        header a:hover{
            color: #0aa1ed;
        }
        /*去掉自带的内边距*/
        .el-table .el-table__cell{
            padding: 0;
            color: #FF6537;
            font: 20px "Microsoft YaHei UI";
        }
        .p_img:hover{
            position: relative;
            bottom: 5px;
            /*元素的阴影:x偏移值 y偏移值 浓度 范围 颜色*/
            box-shadow: 0 0 10px 5px #333;
        }
        div li a{
            color: #FFFFFF;
            font: 16px "Microsoft YaHei UI";
        }
        div li a:hover{
            color: #0aa1ed;
        }
    </style>
</head>
<body>
<div id="app">
    <!--页头组件-->
    <el-page-header style="background-color: #0095d7;color: white;line-height: 60px"
                    @back="goBack" content="修改密码页面"></el-page-header>
    <el-main style="width: 1600px;margin: 0 auto;overflow:hidden">
        <div style="background-color: #0aa1ed;width: 1200px;height: 110px;margin: 0 auto;margin-bottom: 20px">
            <div style="float: left;margin: 10px">
                <img src="imgs/anquan.jpg" alt="">
            </div>
            <div style="float: left;color: white">
                <span><h3>安全小提醒：请补全您的信息</h3></span>
                <span><h3>您与账号安全仅差一步之遥</h3></span>
            </div>
        </div>
        <div style="width: 1200px;margin: 0 auto;text-align: center;margin-top: 30px">
            <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-form-item label="请输入账号" prop="account">
                    <el-input type="accountNumber" v-model="ruleForm.account" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="请输入新密码" prop="pass">
                    <el-input type="password" v-model="ruleForm.pass" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="确认密码" prop="checkPass">
                    <el-input type="password" v-model="ruleForm.checkPass" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                    <el-button @click="resetForm('ruleForm')">重置</el-button>
                </el-form-item>
            </el-form>
        </div>
    </el-main>
</div>
</body>
<!-- import Vue before Element -->
<script src="js/vue.js"></script>
<!-- import JavaScript -->
<script src="js/eui.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data(){
            var validateAccount = (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请输入账号'));
                }else {
                    if (this.ruleForm.account !== '') {
                        this.$refs.ruleForm.validateField('account');
                    }
                    callback();
                }
            };

        var validatePass = (rule, value, callback) => {
            if (value === '') {
                callback(new Error('请输入密码'));
            } else {
                if (this.ruleForm.checkPass !== '') {
                    this.$refs.ruleForm.validateField('checkPass');
                }
                callback();
            }
        };
        var validatePass2 = (rule, value, callback) => {
            if (value === '') {
                callback(new Error('请再次输入密码'));
            } else if (value !== this.ruleForm.pass) {
                callback(new Error('两次输入密码不一致!'));
            } else {
                callback();
            }
        };
            return {
                ruleForm: {
                    account: '',
                    pass: '',
                    checkPass: ''
                },
                rules: {
                    account: [
                        { validator: validateAccount, trigger: 'blur' }
                    ],
                    pass: [
                        { validator: validatePass, trigger: 'blur' }
                    ],
                    checkPass: [
                        { validator: validatePass2, trigger: 'blur' }
                    ],
                },
            }
        },
        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        alert('submit!');
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            },
            goBack(){
                //返回上一页面
                history.back();
            }
        }
    })
</script>
</html>